<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    .box {
      width: 100px;
      height: 100px;
      border: 1px solid red;
    }
  </style>
  <body>
    <div id="app">
      <div class="box" v-if="flag"></div>
      <button @click="handle">出现</button>
      <my-component></my-component>
    </div>
    <script src="https://unpkg.com/vue@next"></script>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            count: 0,
            flag: false,
          };
        },
        mounted() {},
        methods: {
          handle() {
            this.flag = !this.flag;
          },
        },
      });
      app.component("my-component", {
        data() {
          return {
            msg: "this is my first component",
          };
        },
        template: `
        <div>
          {{msg}}
          </div>
        `,
      });
      app.mount("#app");
    </script>
  </body>
</html>
